package com.su.lightthings.fragment

import android.content.Intent
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.su.lightthings.activity.DeviceListActivity
import com.su.lightthings.adapter.AboutPageItemAdapter
import com.su.lightthings.base.BaseFragment
import com.su.lightthings.databinding.FragmentAboutBinding
import com.su.lightthings.utils.Cons

class AboutFragment : BaseFragment<FragmentAboutBinding>() {

    private val mAdapter: AboutPageItemAdapter by lazy {
        AboutPageItemAdapter()
    }

    override fun getViewBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentAboutBinding = FragmentAboutBinding.inflate(layoutInflater)

    override fun initViews() {
        binding.rv.apply {
            adapter = mAdapter
            layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
            isNestedScrollingEnabled = false
            addItemDecoration(
                DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL)
            )
        }
        mAdapter.submitList(Cons.AboutPage.aboutItemList)
        binding.llDeviceCount.setOnClickListener {
            toDeviceListPage()
        }
        binding.btLogout.setOnClickListener {
            logout()
        }
    }

    private fun toDeviceListPage() {
        startActivity(Intent(requireActivity(), DeviceListActivity::class.java))
    }

    private fun logout() {

    }

}